Chris Pollett > Old Classes >
CS134

( Print View )

Student Corner:
  [Grades Sec1]
  [Grades Sec2]

  [Submit Sec1]
  [Submit Sec2]

  [Email List Sec1]
  [Email List Sec2]

  [
Lecture Notes]

Course Info:
  [Texts & Links]
  [Topics]
  [Grading]
  [HW Info]
  [Exam Info]
  [Regrades]
  [Honesty]
  [Announcements]

HW Assignments:
  [Hw1]  [Hw2]  [Hw3]
  [Hw4]  [Hw5]

Practice Exams:
  [Mid1]  [Mid2]  [Final]

                           












HW#2 --- last modified March 02 2019 21:05:37..

Solution set.

Due date: Oct 11

Files to be submitted:
  Bathysphere.zip

Purpose:To gain experience with design patterns used with games and look a little at the animation sequence. To explore forces and physics in games, to create new critters and sprites.

Specification:

A bathysphere is a type of submarine used for deep sea exploration. It is different from a bathyscape in that the former is lowered into the water by a cable; whereas, the latter is not and is self-propelled. For this homework your goal is to create a vertically scrolling game based on bathyspheres. Use the technique of exercise 6.4 to make this game launch in a 500 by 600 sized window. The goal of this game is to carefully navigate your bathysphere onto the top of disabled, powerless, nuclear subs and rescue their stranded sailors.

Bathyspheres are deliberately designed to sink, so in your game I would like your bathysphere to sink according to the force of gravity and its mass. Simulate the sinking by having the the contents of world scroll vertically passed the bathysphere. Besides just the force of gravity, there is another force exerted by the water, which has a certain viscosity and induces an upward drag on the bathysphere, so you should use such a force in your game as well. Your bathysphere is attached to a ship at the surface of the water by a cable. You should make a class cCompositeCritter, using the Composite design pattern, and new critters for the bathysphere, surface ship, and connecting cable. To keep things simple the cable can be assumed to be always vertically above the bathysphere. You might want to make the cable out of more than one critter or make the cable behave like a wall rather the usual spherical behaving critters. The point of having composite critters rather than using composite sprites is to have collisions behave differently depending on what part of the object is hit, but still to have motion of the whole group determined largely by the composite object.

Besides the naturally occuring scrolling because of the bathysphere sinking, the player can also actively control the motion to some extent. First, the left and right arrows can move the player left and right. The horizontal world width, though, should be at most the width of the screen. The player can also hit the space button to signal the surface crew to tension the cable and to start reeling the cable in. Since bathyspheres are quite heavy when the cable starts to be reeled in, it stretches a bit. If the bathysphere has gone to too great a depth the cable can stretch to its breaking point and the bathysphere will meet a watery end. Normally, however, the bathysphere's rate of descent slows, stops, and then the bathysphere starts being reeled to the surface. I would like you to try to model this behaviour using spring forces.

On the left and right hand sides of the screen, one should see the rocky outcrops of the trench the bathysphere is descending into. These can also be modelled using composite critters behaving as walls. The stranded submarine is situated on one of these outcrops. Another reason to use the space bar is to slow the bathysphere so it doesn't damage the sub when it lands on top of it. If the bathysphere comes in too fast the sub and bathysphere collide and there is a nuclear explosion... game over. To make the game more challenging, the ship at the surface typically only uses a small gas-powered winch to pull up the bathysphere. For our game, we pretend that the surface ship is powered by diesel and that only a limited amount of gas was brought along to power the winch. The remaining liters of gasoline are indicated at the bottom of the screen. When these are exhausted, the surface crew has no choice but to cut the cable and let the bathysphere sink to its demise. If the the bathysphere lands at the correct speed on the sub, then the two critters join into one composite (and now heavier object) and can be winched up together. The level is cleared when the bathysphere and sub reach the surface together. Points are awarded depending on how much fuel was left. Then the next level begins and this time the bathysphere falls more rapidly.

Point Breakdown

Departmental coding guidelines for C++ followed 1pt
Look of the game. Images for bathysphere, outcrops, nuclear subs, cable,etc 2pts
Forces on bathysphere for gravity, water drag, and tensioning cable as described above3pts
A composite critter class is developed and used for the bathysphere, surface ship and cable combo 2pts
Sub appears on a rocky outcrop as described above 2pts
Player dies if bathysphere: (a) is moving too fast when cable tensioned, (b) hits a outcrop or lands sub too fast, (c) runs out of gasoline.3pts
Bathysphere can return to surface with sub1pt
When return to surface the score is calculated and new level begins with bathysphere falling faster1pt
Total15pts